<!--
    //
    //author:化缘
-->

window.onload=function(){
 
	function getecomelist(){
    var data1;

	   $.post(".../../../control/ecome/slarymanager.php",function(data,status){
    	
       var jsonobj=eval('('+data+')');
       data1=data;
       $("#pagesize").text(jsonobj[0].pagecount);
       // alert(jsonobj.length);
       //alert(jsonobj[0].studentid);
       for (var i = 0; i<jsonobj.length; i++){

         var price="<tr><td>"+jsonobj[i].college+"</td><td>"+jsonobj[i].studentid+"</td><td>"
         +jsonobj[i].studentname+"</td><td>"+jsonobj[i].workbegin+
         "</td><td>"+jsonobj[i].workalltime+"</td><td><a"+" href='changslary.php?studentid="+jsonobj[i].studentid+"'> "+jsonobj[i].price+" </a> </td></tr>";
         $('#totalprice').append(price); 

       }
       return data1;
       

  });
 
}

//post传数据去
function postdata(pagesize){
  $.post(".../../../control/ecome/slarymanager.php",
          {
            currentpage:pagesize     //传进去页数
          },function(data,status){
             var jsonobj=eval('('+data+')');
        for (var i = 0; i<jsonobj.length; i++){

         var price="<tr><td>"+jsonobj[i].college+"</td><td>"+jsonobj[i].studentid+"</td><td>"
         +jsonobj[i].studentname+"</td><td>"+jsonobj[i].workbegin+
         "</td><td>"+jsonobj[i].workalltime+"</td><td><a"+" href='changslary.php?studentid="+jsonobj[i].studentid+"'> "+jsonobj[i].price+" </a> </td></tr>";
         $('#totalprice').append(price); 
         
        }
      }
    );


}

// 点击上 下一页显示
  function getpager(allpagesize,currentpage){

    var showcurrentpage=currentpage+"/"+allpagesize;
    $("#currentpage").text(showcurrentpage);
    $("#nextpage").click(function(){
     if(currentpage<(allpagesize)){
      showcurrentpage=currentpage+"/"+allpagesize;
       $("#currentpage").text(showcurrentpage);//显示当前页面显示
       postdata(currentpage+1);  //提交下一页的数据

      }else{
        $("#nextpage").hide("slow");
      }
    });
     //点击上一页显示
    $("#prepage").click(function(){
       if(currentpage>1){
          showcurrentpage=currentpage+"/"+allpagesize;
          $("#currentpage").text(showcurrentpage);//显示当前页面显示
           postdata(currentpage-1);
       }else{
        $("#prepage").hide("slow");
       }
    });

  }

function getpage(){
  var count=$("#pagesize").text();
  alert(count);

}
getecomelist(); 


setTimeout(function(){
  var allpage=$("#pagesize").text();

  getpager(allpage,1);

},1500);


}